package org.prism.string;

import org.junit.Test;

import java.util.TreeSet;

public class StringTest {
    public static void main(String[] args) {
        String s1 = "javaEEMysql";
        String s2 = "javaEE";
        String s3 = s2 + "Mysql";
        System.out.println(s1 == s3);
        String s4 = "javaEE";
        String s5 = s4 + "Mysql";
        System.out.println(s1 == s5);
    }
    public void trim(){
        String str = "";

    }
    @Test
    public void sort(){
        TreeSet<Person> sets = new TreeSet<>();
//        sets.add(1);
//        sets.add(2);
//        sets.add(7);
//        sets.add(6);
//        sets.add(-1);
//        sets.add(-15);
//        sets.addAll(Arrays.asList(-5,-6,-8,1,9,3,7));
        sets.add(new Person("tom",1));
        sets.add(new Person("jay",63));
        sets.add(new Person("mey",4));
        sets.add(new Person("jack",8));
        sets.add(new Person("jar",72));
        System.out.println("sets = " + sets);
    }
}
class Person implements Comparable<Person>{
    private String name;
    private Integer age;

    public Person(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public int compareTo(Person o) {
        return Integer.compare(o.age,this.age);
    }
}
